﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using t_205_verk_hopur_12.Models;

namespace t_205_verk_hopur_12.Helpers
{
    public class Tool : t_205_verk_hopur_12.Helpers.ITool
    {
        UserRepository userRepo = new UserRepository();

        // Returnes the logged in user
        // Can use another repository, this is used if you are going to change the
        // user information
        public User GetCurrentUser(UserRepository argUserRepo)
        {
            return argUserRepo.GetUserInfoByUsername(Membership.GetUser().UserName);
        }

        // Returnes the logged in user
        public User GetCurrentUser()
        {
            if(Membership.GetUser() != null)
            {
                return userRepo.GetUserInfoByUsername(Membership.GetUser().UserName);
            }

            return null;
        }
    }
}
